<?php
session_start(); //开启会话
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" type="text/css" href="css/demo.css"/>
    <link rel="stylesheet" type="text/css" href="css/style.css"/>
    <link rel="stylesheet" type="text/css" href="css/animate-custom.css"/>
    <title>会员登录日志</title>
    <style>
        h1 {
            text-align: center
        }

        table {
            text-align: center;
            width: 450px;
           position: relative;
            top: 20px;
        }
        td {
            width: 8.5%;
            padding: 8px;
        }
        #b  {
            width: 500px;
            position: relative;
            left: -6%;
            margin-top: 20px;
        }
        tr {
            width: 100%;
            border: 1px solid rgba(147, 184, 189, 0.8);
            border-radius: 5px;
            box-shadow: 0pt 2px 5px rgba(105, 108, 109, 0.7), 0px 0px 8px 5px rgba(208, 223, 226, 0.4) inset;
        }

        td:hover {
            transform: translateY(-5px);
            transition-duration: 0.3s;
        }

        li {
            float: left;
            width: 8%;
            position: relative;
            left: 38%;
            font-size: 20px;
            padding-top: 1%;
        }
    </style>
</head>
<body>
<div class="container">
    <header>
        <h1><span>会员列表</span></h1>
        <nav class="codrops-demos">

        </nav>
        <nav>
            <ul>
                <li><a href="index.php"><strong>首页</strong></a></li>
                <li><a href="admin.php"> <strong>管理员中心</strong></a></li>
                <li><a href="zhuxiao.php"> <strong>注销</strong></a></li>
            </ul>
        </nav>
    </header>
    <section>
        <div id="container_demo">
            <div id="wrapper">
                <div id="login" class="animate form">
                    <?php
                    //先判断是否管理员登录，本页面只有管理员才能访问
                    if (!isset($_SESSION['admin']) or !$_SESSION['admin']) {  //说明未登录
                        echo "<script>alert('本页面需要管理员才能访问，请以管理员身份登录！');location.href='login.html';</script>";
                        exit;
                    }
                    include_once "conn.php";
                    $sql = "select username,sj from sss,userinfo where sss.userid = userinfo.id order by sss.userid desc";
                    $result = mysqli_query($conn, $sql);
                    include_once "page.php";
                    $count_rows = mysqli_num_rows($result);
                    //引用分页函数
                    $perPage = 10;
                    pageft($count_rows, $perPage, $count_rows);
                    $sql .= " limit $firstcount, $displaypg";
                    $result = mysqli_query($conn, $sql);
                    ?>
                    <table align="center" style="border-collapse: collapse" border="1" bordercolor="#999999">
                        <tr>
                            <td>序号</td>
                            <td>用户名</td>
                            <td>登录时间</td>
                        </tr>
                        <?php
                        $page = isset($_GET['page']) ? $_GET['page'] : 1;
                        $i = ($page - 1) * $perPage + 1;
                        while ($info = mysqli_fetch_array($result)) {
                            ?>
                            <tr>
                                <td><?php echo $i ?></td>
                                <td><?php echo $info['username'] ?></td>
                                <td><?php echo date("Y-m-d H:i:s", $info['sj']); ?></td>
                            </tr>
                            <?php
                            $i++;
                        }
                        ?>
                    </table>
                    <table id="b">
                        <tr>
                            <td align="right"><?php
                                //页尾显示
                                echo $pagenav;
                                ?></td>
                        </tr>
                    </table>

                </div>
            </div>
        </div>
    </section>
</body>
</html>